<style>
    .t_input{
        margin-left:10px;
        margin-bottom: 10px;
    }
</style>
<!-- MAIN CONTENT -->

<div id="content">

    <div smart-include="app/yksensor/views/sub-header.tpl.html"></div>

    <div class="clearfix margin-bottom-10">
        <div class="pull-left margin-right-20" ng-show="alarm">
            <a class="btn btn-labeled btn-primary" data-toggle="modal" data-target="#addAlert"> <span class="btn-label"><i class="glyphicon glyphicon-plus"></i></span>添加报警设置</a>
        </div>

        <!-- <div class="pull-left margin-left-25">

            <strong class="font-md">是否处理：</strong>
            <label class="input">

                <select name="" id="" class="form-control ipt_form" ng-model="paginationConf.handle">
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
            </label>

          
        </div>
        <div class="pull-left margin-right-20">
            <a class="btn btn-primary btn-sm" href-void="" ng-click="search()">查询</a>
        </div> -->
    </div>
    <div class="table-responsive">
        <table class="table table-bordered table-hover no-margin font-sml table-striped sensor_table">
            <thead>
                <tr>
                    <th ng-show="alarm">操作</th>
                    <th class="text-align-center">设备编号</th>
                    <th class="text-align-center">报警类型</th>
                    <th class="text-align-center">通知类型</th>
                    <!-- <th class="text-align-center">报警级别</th> -->
                    <th class="text-align-center">报警字段</th>
                    <th class="text-align-center">报警值</th>
                    <th class="text-align-center">创建时间</th>
                    <th class="text-align-center">创建账号</th>
                </tr>
            </thead>
            <tbody>

                <tr ng-repeat="data in datas">
                    <td ng-show="alarm">
                        <button class='btn btn-xs btn-default' uib-tooltip='编辑' tooltip-append-to-body='true' ng-click="showEditAlert(data)"><i class='fa fa-pencil'></i></button>
                        <button class='btn btn-xs btn-default' uib-tooltip='删除' tooltip-append-to-body='true' ng-click="showDelDialog(data.id)"><i class='fa fa-times'></i></button>
                    </td>
                    <td class="text-align-center" class="deviceid">{{data.deviceid}}</td>
                    <td class="text-align-center">
                        {{data.warn_type == 1 ? '上限报警' :(data.warn_type == 2 ? '下限报警' : (data.warn_type == 3 ? '其他报警' : (data.warn_type == 4 ? '等级报警' : '' )))
                     }}
                    </td>
                    <td class="text-align-center">{{data.notice_type == 0 ? '不通知' :(data.notice_type == 1 ? '短信通知' : (data.notice_type == 2 ? '公众号通知' : (data.notice_type == 3 ? '都通知' : (data.notice_type == 4 ? '转发post' : '' )))) }}</td>
                    <!-- <td class="text-align-center">{{data.warn_grade == 1 ? '一级报警' :(data.hintvoice == 2 ? '二级报警' : '') }}</td> -->
                    <td class="text-align-center">{{data.fieldname == "flow" ? "流量" : (data.fieldname == "pos" ? "液位" : (data.fieldname == "temp" ? "温度" : data.fieldname)) }}</td>
                    <td class="text-align-center">{{data.value}}</td>
                    <td class="text-align-center">{{data.time | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                    <td class="text-align-center">{{data.fid}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <!-- end widget content -->
    <div class="dt-toolbar-footer">
        <tm-pagination conf="paginationConf"></tm-pagination>
    </div>

    <div class="modal fade" id="addAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">添加警告设置</h4>
                </div>
                <div class="modal-body">

                    <form id="smart-form-register" class="smart-form" data-smart-registration-form ng-submit="insertdata()">
                        <fieldset class="row">
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">设备编号</label>
                                <label class="select">
                                    <select class="input-sm" ng-model="insert.deviceid" >
                                        <option ng-repeat="item in alldevice" value="{{item.deviceid}}">{{item.deviceid}}</option>
                                    </select> <i></i>
                                </label> 

                            </section> 
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">报警类型</label>
                                <label class="select">
                                    <select name="" id="" required="required" ng-model="insert.warn_type">
                                        <option value="1">上限报警</option>
                                        <option value="2">下限报警</option>
                                        <!-- <option value="3">其他报警</option>
                                        <option value="4">等级报警</option> -->
                                    </select>
                                </label>
                            </section>
                            <!-- <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">通知类型</label>
                                <label class="select">
                                    <select name="" id="" required="required" ng-model="insert.notice_type">
                                        <option value="0">不通知</option>
                                        <option value="1">短信通知</option>
                                        <option value="2">公众号通知</option>
                                        <option value="3">都通知</option>
                                        <option value="4">转发post</option>
                                    </select>
                                </label>
                            </section> -->
                            <!-- <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">报警级别</label>
                                <label class="select">
                                    <select name="" id="" required="required" ng-model="insert.warn_grade">
                                        <option value="1">一级报警</option>
                                        <option value="2">二级报警</option>
                                    </select>
                                </label>
                            </section> -->
                            <section class="col-sm-5" style="margin: 0 20px 15px;">
                                <label class="label">报警字段</label>
                                <label class="select">
                                    <select name="" id="" required="required" ng-model="insert.fieldname" ng-change="changeField(insert.fieldname)">
                                        <option value="pos">液位</option>
                                        <option value="flow">流量</option>
                                        <option value="temp">温度</option>
                                    </select>
                                </label>
                            </section>
                            <section class="col-sm-5" style="margin: 0 20px 15px;" ng-if="!isTemp">
                                <label class="label">报警值</label>
                                <label class="input">
                                    <input type="text" maxlength="50" required="required" ng-model="insert.value">
                                </label>
                            </section>
                            <section class="col-sm-11" style="margin: 0 20px 15px;" ng-if="isTemp">
                                <label class="label">温度报警值</label>
                                <div class="row" style="margin: 0 0 0;">
                                    <label class="input">
                                        <input type="text" maxlength="50" required="required" ng-model="insert.value">
                                    </label>
                                </div>
                            </section>
                        </fieldset>

                        <footer>

                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                关闭
                            </button>
                            <button type="submit" class="btn btn-primary">
                                提交
                            </button>

                        </footer>
                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="editAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">编辑警告设置</h4>
                </div>
                <div class="modal-body">

                    <form id="smart-form-register" class="smart-form" data-smart-registration-form ng-submit="updatedata()">
                            <fieldset class="row">
                                <section class="col-sm-5" style="margin: 0 20px 15px;">
                                    <label class="label">设备编号</label>
                                    <label class="select">
                                        <select class="input-sm" ng-model="editdata.deviceid" >
                                            <option ng-repeat="item in alldevice" value="{{item.deviceid}}">{{item.deviceid}}</option>
                                        </select> <i></i>
                                    </label> 
    
                                </section> 
                                <section class="col-sm-5" style="margin: 0 20px 15px;">
                                    <label class="label">报警类型</label>
                                    <label class="select">
                                        <select name="" id="" required="required" ng-model="editdata.warn_type">
                                            <option value="1">上限报警</option>
                                            <option value="2">下限报警</option>
                                            <!-- <option value="3">其他报警</option>
                                            <option value="4">等级报警</option> -->
                                        </select>
                                    </label>
                                </section>
                                <!-- <section class="col-sm-5" style="margin: 0 20px 15px;">
                                    <label class="label">通知类型</label>
                                    <label class="select">
                                        <select name="" id="" required="required" ng-model="editdata.notice_type">
                                            <option value="0">不通知</option>
                                            <option value="1">短信通知</option>
                                            <option value="2">公众号通知</option>
                                            <option value="3">都通知</option>
                                            <option value="4">转发post</option>
                                        </select>
                                    </label>
                                </section>
                                <section class="col-sm-5" style="margin: 0 20px 15px;">
                                    <label class="label">报警级别</label>
                                    <label class="select">
                                        <select name="" id="" required="required" ng-model="editdata.warn_grade">
                                            <option value="1">一级报警</option>
                                            <option value="2">二级报警</option>
                                        </select>
                                    </label>
                                </section> -->
                                <section class="col-sm-5" style="margin: 0 20px 15px;">
                                    <label class="label">报警字段</label>
                                    <label class="select">
                                        <select name="" id="" required="required" ng-model="editdata.fieldname" ng-change="changeField(editdata.fieldname)">
                                            <option value="pos">液位</option>
                                            <option value="flow">流量</option>
                                            <option value="temp">温度</option>
                                        </select>
                                    </label>
                                </section>
                                <section class="col-sm-5" style="margin: 0 20px 15px;" ng-if="!isTemp">
                                    <label class="label">报警值</label>
                                    <label class="input">
                                        <input type="text" maxlength="50" required="required" ng-model="editdata.value">
                                    </label>
                                </section>
                                <section class="col-sm-11" style="margin: 0 20px 15px;" ng-if="isTemp">
                                    <label class="label">温度报警值</label>
                                    <div class="row" style="margin: 0 0 0;">
                                        <label class="input">
                                            <input type="text" maxlength="50" required="required" ng-model="editdata.value">
                                        </label>
                                    </div>
                                </section>
                            </fieldset>

                        <footer>

                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                关闭
                            </button>
                            <button type="submit" class="btn btn-primary">
                                提交
                            </button>

                        </footer>
                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="showDelDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h4 class="modal-title">信息</h4>
                </div>
                <div class="modal-body">
                    <p>
                        您确实要删除这个报警事件吗？
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" class="btn btn-primary" ng-click="deldevice()">
                        删除
                    </button>
                </div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
    <!-- /.modal-dialog -->


</div>
<!-- END MAIN CONTENT -->

